<div class="layui-fluid nepadmin-pad0 nepadmin-mar0 list0" id="list" lay-title="提款列表">
	<div class="layui-fluid">
		<div class="layui-row layui-col-space15">
			<div class="layui-col-md12">
				<div class="layui-card hxr-layui-card" id="userlistv">
					<div class="layui-form hxradmin-card-header">
						<div class="layui-form-item">
							<div class="layui-inline">
								<label class="layui-form-label">代理用户名</label>
								<div class="layui-input-inline">
									<input type="text" name="user" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-inline">
								<label class="layui-form-label" style="width: 85px;">提现日期范围</label>
								<div class="layui-input-inline" style="width: 200px;">
									<input type="text" name="val2" id='date' class="layui-input" readonly>
								</div>
							</div>
							<div class="layui-inline">
								<label class="layui-form-label">状态</label>
								<div class="layui-input-inline">
									<div class="layui-unselect layui-form-select">
										<div class="layui-select-title"><input name="status" type="text" value="" readonly class="layui-input layui-unselect"><i
											 class="layui-edge"></i></div>
										<dl class="layui-anim layui-anim-upbit" style="">
											<dd lay-value="" class="layui-select-tips layui-this">请选择状态</dd>
											<dd data='0'>审核中</dd>
											<dd data='1'>已完成</dd>
											<dd data='2'>已拒绝</dd>
										</dl>
									</div>
								</div>
							</div>
							<div class="layui-inline">
								<button class="layui-btn" data-type="reload" id="drawingssearch">搜索</button>
							</div>
							<div class="layui-inline">
								<button class="layui-btn" data-type="excel" id="pexcel">导出数据</button>
							</div>
						</div>
					</div>
					<div class="layui-card-body">
						<!-- <div>
							<button class="layui-btn layuiadmin-btn-list" data-type="set">提款设置</button>
						</div>{{#  if(d.status === 0){ }} {{#  } }}-->
						<table class="layui-hide" id="list-table" lay-filter="list-table"></table>
					</div>
				</div>
				<script type="text/html" id="list-toolbar">
					{{#  if(d.status === 0){ }}
					<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>同意</a>
					<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>驳回</a>
					{{# }else{ }}
					暂无操作
					{{#  } }}
				</script>
				<script type="text/html" id="status">
				  {{#  if(d.status === 0){ }}
				    <span class="layui-badge layui-bg-blue">申请中</span>
				  {{#  } else if(d.status === 1) { }}
				    <span class="layui-badge layui-bg-green">已完成</span>
					{{#  } else if(d.status === 2) { }}
					  <span class="layui-badge layui-bg-cyan">已拒绝</span>
				  {{#  } }}
				</script>
				<script type="text/html" id="bank_name">
					{{#  if(d.pay_type ==1){ }}
					{{d.bank_name}}-{{d.bank_account}}
					{{#  } }}

				</script>
			</div>
		</div>
	</div>
</div>
<script>
	var formurl='drawings/drawingsform',formarea=['500px', '630px'];
	//表格数据渲染
	
	layui.use(['table', 'form','laydate'], function() {
		var table = layui.table,
			form = layui.form,
			$ = layui.$,laydate=layui.laydate;;
			//日期范围
			  laydate.render({
			    elem: '#date'
			    ,range: true
			  });
			layui.admin.initlist(table,'withdraw/replay_list',240,[
						[{
							field: 'agent_withdraw_id',
							title: 'ID',
							width: 60
						},{
							field: 'hotel_name',
							title: '酒店/学校',
							minwidth: 180
						},{
							field: 'pay_type_name',
							title: '到账方式',
							minWidth: 130
						}, {
							field: 'bank_name',
							title: '开户行名称',
							minwidth: 200,
							templet:'#bank_name'
						}, {
							field: 'withdraw_amount',
							title: '提现金额(元)',
							width: 110
						}, {
							field: 'withdraw_fee',
							title: '手续费(元)',
							width: 100
						}, {
							field: 'should_amount',
							title: '实际到账金额(元)',
							width: 110
						}, {
							field: 'before_balance',
							title: '变动前(元)',
							width: 100
						},{
							field: 'after_balance',
							title: '变动后(元)',
							width: 100
						},
						{
							field: 'reject_reason',
							title: '拒绝理由',
							minWidth: 100
						},
						{
							field: 'status',
							title: '状态',
							width: 100,
							templet: '#status'
						},{
							field: 'create_time',
							title: '提现时间',
							width: 200
						}, {
							title: '操作',
							toolbar: '#list-toolbar',
							width: 150,
							fixed:'right'
						}]
					])

		//监听表格操作事件
		table.on('tool(list-table)', function(obj) {
			var data = obj.data;
			//处理
			if (obj.event === 'del') {//驳回
				layer.prompt({
				    formType: 2,
				    title: '输入驳回原因',
				    yes: function(index, layero){
				        var value = layero.find(".layui-layer-input").val();
						if(value){
							layui.admin.ajax('withdraw/review',{status:2,agent_withdraw_id:data.agent_withdraw_id,reject_reason:value}).then(function(res){
									table.reload('list-table');
									layer.close(index);
							});
						}else{
							layer.msg('请输入驳回原因');
						}
				    }
				});
			} else if (obj.event === 'edit') { //同意
				layer.confirm('确定通过申请?', function(index) {
					layui.admin.delF(table,'withdraw/review',{agent_withdraw_id:data.agent_withdraw_id,status:1});
				});
			}
		});


		//监听行双击事件
		/* table.on('rowDouble(list-table)', function(obj) {
			//查看详情
			layui.admin.pupF('提款详情', formarea, formurl, 3, obj.data);
		});
		var active = {
			set: function() {
					layui.admin.pupF('提款设置',formarea,formurl, 2);
				}
		}; */
		//操作dom
		$('.layui-btn.layuiadmin-btn-list').on('click', function() {
			var type = $(this).data('type');
			active[type] ? active[type].call(this) : '';
		});
		//搜索
		$('#drawingssearch').on('click', function() {
			var obj=$(this).parents('.layui-form-item');
			var val1 = obj.find('input[name="user"]').val();
			var val2 = obj.find('input[name="val2"]').val();
			var val3 = obj.find('input[name="status"]').attr('data');
			layui.admin.reloads({
				search_text: val1,
				datemin:val2.split(' ')[0],
				datemax:val2.split(' ')[2],
				status:val3
			})
		});
		//导出
		$('#pexcel').on('click', function() {
			var obj=$(this).parents('.layui-form-item');
			var val1 = obj.find('input[name="user"]').val();
			var val2 = obj.find('input[name="val2"]').val();
			var val3 = obj.find('input[name="status"]').attr('data');
			layui.admin.excel(table,'withdraw/replay_list',
					{
						search_text: val1,
						datemin:val2.split(' ')[0],
						datemax:val2.split(' ')[2],
						status:val3
					},'');
		});
	});
</script>
